package cn.liuhuan1.blogsModel.controller;


import cn.liuhuan1.entity.ReturnResult;
import cn.liuhuan1.webModelBean.api.WebUserImp;
import cn.liuhuan1.webModelBean.vo.WebUserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/webUser")
public class WebUserController {

    @Autowired
    private WebUserImp webUserImp;

    @RequestMapping(value = "/getWebUser",method = RequestMethod.GET)
    @ResponseBody
    public ReturnResult getWebUser(){
        List<WebUserVo> getWebUser = webUserImp.getWebUser();
        return ReturnResult.succes(getWebUser);
    }

    @RequestMapping(value = "/register",method = RequestMethod.POST)
    @ResponseBody
    public ReturnResult register(@RequestBody WebUserVo webUserVo){
        return webUserImp.register(webUserVo,webUserVo.getAuthCode());
    }

    @RequestMapping(value = "/loginWebUser",method = RequestMethod.GET)
    @ResponseBody
    public ReturnResult loginWebUser(@RequestParam("email") String email,
                                     @RequestParam("password") String password){
        return webUserImp.loginWebUser(email,password);
    }
}
